import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] cost = new int[n];
        for (int i = 0; i < n; i++) {
            cost[i] = sc.nextInt();
        }
        if(n == 1) {
            System.out.println(0);
        }
        int[] dp = new int[n+1];
        dp[0] = cost[0];
        dp[1] =Math.min(cost[0],cost[1]);
        for (int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i-1],dp[i-2]) + cost[i];
        }
         dp[n] = Math.min(dp[n-1],dp[n-2]);
        System.out.println(dp[n]);
    }
}